#!/bin/bash
if [ ! -d "/usr/share/kylin-connectivity" ]; then
    mkdir /usr/share/kylin-connectivity
fi
cp ./build/kylin-connectivity /usr/bin/
cp ./kylin-connectivity.desktop /usr/share/applications/
cp ./third_party/scrcpy-server.jar /usr/share/kylin-connectivity/
cp ./third_party/sndcpy /usr/share/kylin-connectivity/
cp -r ./translations/ /usr/share/kylin-connectivity/
cp ./output/lib/plugin/libpeony-vfs-kylin-multiterminal.so /lib
cp ./output/lib/plugin/libpeony-send-to-connectivity.so /lib

if [ ! -d "/opt/kylin-connectivity/" ]; then
    mkdir /opt/kylin-connectivity/
fi

cp ./output/bin/* /opt/kylin-connectivity/

#arch
get_arch=`uname -i`
if [[ $get_arch =~ "x86_64" ]];then
    mv /lib/libpeony-vfs-kylin-multiterminal.so /lib/x86_64-linux-gnu/peony-extensions/
    mv /lib/libpeony-send-to-connectivity.so /lib/x86_64-linux-gnu/peony-extensions/
elif [[ $get_arch =~ "aarch64" ]];then
    mv /lib/libpeony-vfs-kylin-multiterminal.so /lib/aarch64-linux-gnu/peony-extensions/
    mv /lib/libpeony-send-to-connectivity.so /lib/aarch64-linux-gnu/peony-extensions/
else
    echo "unknown!!"
fi

